//
//  JXStatusModel.swift
//  swift高仿微博
//
//  Created by peijiaxing on 16/2/29.
//  Copyright © 2016年 peijiaxing. All rights reserved.
//

import UIKit

class JXStatusModel: NSObject {
    
    // cell 的 ID
    var id : Int = 0
    
    ///  created_at	string	微博创建时间
    var created_at: String?
    /// text	string	微博信息内容
    var text: String?
    ///source	string	微博来源
    var source: String?
    
    // 用户模型
    var user: JXStatusUserModel?
    
    ///reposts_count	int	转发数
    var reposts_count: Int = 0
    ///comments_count	int	评论数
    var comments_count: Int = 0
    ///attitudes_count	int	表态数
    var attitudes_count: Int = 0
    ///retweeted_status	object	被转发的原微博信息字段，当该微博为转发微博时返回 详细
    var retweeted_status: JXStatusModel?
    
    // 定义一个数组  并初始化
    var pic_urls:[JXPictureModel]?
    
    init(dic: [String: NSObject]) {
        
        super.init()
        
        // 调用kvc
        setValuesForKeysWithDictionary(dic)
        
        if let userDic = dic["user"] as? [String: NSObject]{
            // 获取到 user的字典,然后进行字典转模型
            user = JXStatusUserModel(dic: userDic)
            
        }
        
        if let retweetDic = dic["retweeted_status"] as? [String: NSObject]{
            retweeted_status = JXStatusModel(dic: retweetDic)
        }
        
        if let pic_Urls = dic["pic_urls"] as? [[String: NSObject]]{
            
            pic_urls = [JXPictureModel]()
            
            for info in pic_Urls{
               
                pic_urls?.append(JXPictureModel(dic: info))
            }
        }
    }
    
    //防止崩溃
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
}
